package com.study.chapter11;

import org.apache.flink.api.java.ExecutionEnvironment;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.table.api.EnvironmentSettings;
import org.apache.flink.table.api.TableEnvironment;
import org.apache.flink.table.api.bridge.java.BatchTableEnvironment;
import org.apache.flink.table.api.bridge.java.StreamTableEnvironment;

/**
 * @Description:
 * @Author: LiuQun
 * @Date: 2022/8/19 21:16
 */
public class TableEnvironmentTest {
    public static void main(String[] args) throws Exception {
        //1.使用流处理环境创建表环境
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        StreamTableEnvironment tableEnv1 = StreamTableEnvironment.create(env);

        //2.定义环境配置来创建表执行环境，流处理
        EnvironmentSettings settings = EnvironmentSettings.newInstance()
                .inStreamingMode()
                .useBlinkPlanner()
                .build();
        TableEnvironment tabEnv2 = TableEnvironment.create(settings);

        //定义环境配置来创建表执行环境，批处理
        EnvironmentSettings settings4 = EnvironmentSettings.newInstance()
                .inBatchMode()
                .useBlinkPlanner()
                .build();
        TableEnvironment tabEnv4 = TableEnvironment.create(settings4);

        //3.基于老版本Planner进行流处理
        EnvironmentSettings settings3 = EnvironmentSettings.newInstance()
                .inStreamingMode()
                .useOldPlanner()
                .build();
        TableEnvironment tabEnv3 = TableEnvironment.create(settings3);

        //4.基于老版本Planner进行批处理
        ExecutionEnvironment batchEnv = ExecutionEnvironment.getExecutionEnvironment();
        BatchTableEnvironment batchTableEnvironment = BatchTableEnvironment.create(batchEnv);

        env.execute();
    }
}
